/**************************************************************************************************

	NSurvey - The web survey and form engine
	Copyright (c) 2004, Thomas Zumbrunn. (http://www.nsurvey.org)

	Dotnetnuke PA module 
	Copyright (c) 2004, Oliver Hine (oliver.hine@gmail.com)

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


************************************************************************************************/
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using DotNetNuke;
using Votations.NSurvey.WebControls;


namespace Votations.NSurvey.WebAdmin
{
	public class nSurvey: PageBase, DotNetNuke.Entities.Modules.IActionable 
	{

		#region Optional Interfaces
		public DotNetNuke.Entities.Modules.Actions.ModuleActionCollection ModuleActions 
		{ 
			get 
			{ 
				DotNetNuke.Entities.Modules.Actions.ModuleActionCollection Actions = new DotNetNuke.Entities.Modules.Actions.ModuleActionCollection(); 
				Actions.Add(GetNextActionID(), "nSurveyAdmin", DotNetNuke.Entities.Modules.Actions.ModuleActionType.AddContent, "", "", EditUrl("Edit"), false, DotNetNuke.Security.SecurityAccessLevel.Edit, true, false); 
				Actions.Add(GetNextActionID(), "Active Survey Selector", DotNetNuke.Entities.Modules.Actions.ModuleActionType.AddContent, "", "", EditUrl("Settings"), false, DotNetNuke.Security.SecurityAccessLevel.Edit, true, false); 
				Actions.Add(GetNextActionID(), "New Survey", DotNetNuke.Entities.Modules.Actions.ModuleActionType.AddContent, "", "", EditUrl("CreateSurvey"), false, DotNetNuke.Security.SecurityAccessLevel.Edit, true, false); 
				return Actions; 
			} 
		}
		#endregion

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);
		}
		#endregion

		protected SurveyBox Survey;

		private void Page_Load(Object sender, EventArgs e)
		{
			if (Settings.Contains("SurveyId"))
			{
				try
				{
					Survey.SurveyId = int.Parse(Settings["SurveyId"].ToString());
				}

				catch
				{
					Survey.Visible = false;
					Literal lit = new Literal();
					lit.Text = "Survey not found, please select another!";
					this.Controls.Add(lit);
				}
				
			}
			else
			{
				Survey.Visible = false;
				Literal lit = new Literal();
				lit.Text = "No Survey Selected!";
				this.Controls.Add(lit);
			}
		}

		
	}
}
